#:kivy 1.0.9
#:import PythonLexer pygments.lexers.python.PythonLexer

<LoadDialog>:
    BoxLayout:
        size: root.size
        pos: root.pos
        orientation: "vertical"
        FileChooserListView:
            id: filechooser
            path: './configs/'

        BoxLayout:
            size_hint_y: None
            height: 30
            Button:
                text: "Cancel"
                on_release: root.cancel()

            Button:
                text: "Load"
                on_release: root.load(filechooser.path, filechooser.selection)

<SaveDialog>:
    text_input: text_input
    BoxLayout:
        size: root.size
        pos: root.pos
        orientation: "vertical"
        FileChooserListView:
            id: filechooser
            on_selection: text_input.text = self.selection and self.selection[0] or ''
            path: './configs/'
        TextInput:
            id: text_input
            size_hint_y: None
            height: 30
            multiline: False

        BoxLayout:
            size_hint_y: None
            height: 30
            Button:
                text: "Cancel"
                on_release: root.cancel()

            Button:
                text: "Save"
                on_release: root.save(filechooser.path, text_input.text)
    
<EditorScreen>:  
    scrlv: scrlv
    spinner: spinner
    index_label: index_label
    up_button:up_button
    down_button:down_button
    save_button:save_button
    close_button:close_button
    codeinput:codeinput
    index_label_bcolor: [0,0,0,1]
    BoxLayout:
        orientation: 'vertical'
        opacity:1
        BoxLayout:
            orientation: 'horizontal'
            size_hint: (None, None)
            size: (root.width, 44)
            Spinner:
                id: spinner
                size_hint: (None, None)
                size: (root.width-280, 44)
                text: '新建'
                values: ['新建', '打开']
                on_text: root.on_select(self, self.text)
            Button:
                id: up_button
                size_hint: (None, None)
                size: (50, 44)
                text: '▼'
                on_press: root.on_up(self)
            Label:
                id: index_label
                size_hint: (None, None)
                size: (80, 44)
                text: '序号:0'
                canvas.before:
                    Color:
                        rgba: root.index_label_bcolor
                    Rectangle:
                        pos: self.pos
                        size: self.size
            Button:
                id: down_button
                size_hint: (None, None)
                size: (50, 44)
                text: '▲'
                on_press: root.on_down(self)
            Button:
                id: save_button
                size_hint: (None, None)
                size: (50, 44)
                text: '保存'
                on_press: root.on_save(self)
            Button:
                id: close_button
                size_hint: (None, None)
                size: (50, 44)
                text: '关闭'
                on_press: root.on_close(self)
        ScrollView:
            id: scrlv
            bar_width: 5
            CodeInput:
                id: codeinput
                size_hint: 1, None
                height: max(self.minimum_height, scrlv.height)
                lexer: PythonLexer()
                valign: "top"
                on_text: root.on_text()

<GestureScreen>:    
    # canvas:
    #     Rectangle:
    #         pos: self.center_x - 5, 0
    #         size: 10, self.height
            
    # Label:
    #     font_size: 70  
    #     center_x: root.width / 4
    #     top: root.top - 50
    #     text: "0"
        
    # Label:
    #     font_size: 70  
    #     center_x: root.width * 3 / 4
    #     top: root.top - 50
    #     text: "0"
    scrlv: scrlv
    textoutput: textoutput
    imgeoutput: imgeoutput
    poseoutput: poseoutput
    splitterbottom: splitterbottom
    
    # BoxLayout:
    orientation: 'vertical'
    size: root.width, root.height
    Splitter:
        id: splitterbottom
        sizable_from: 'bottom'
        min_size: 13
        size_hint: (1,0)
        BoxLayout:
            orientation: 'horizontal'
            size: root.width, root.height
            Splitter:
                sizable_from: 'right'
                min_size: 13
                max_size: root.width
                size_hint: (0.67,1)
                Image:
                    id: imgeoutput
                    color: (0,0,0,1)
            TextInput:
                id: poseoutput
                readonly: True
                background_normal: 'atlas://data/images/defaulttheme/textinput_active'
                size_hint: (0.33,1)
    ScrollView:
        id: scrlv
        bar_width: 5
        TextInput:
            id: textoutput
            size_hint: 1, None
            height: max(self.minimum_height, scrlv.height)
            readonly: True
            background_normal: 'atlas://data/images/defaulttheme/textinput_active'
            # size: root.width, root.height
    

<TopScreen>: 
    eswidget:eswidget
    gswidget:gswidget
    BoxLayout:
        orientation: 'horizontal'
        size: root.width, root.height
        Splitter:
            id: gswidget
            sizable_from: 'right'
            min_size: 13
            max_size: root.width-400
            size_hint: (1,1)
        BoxLayout:
            id: eswidget
            size_hint: (0,1)
        
        